package sam.learning.eurekaserver;

import sun.misc.Unsafe;

import java.lang.reflect.Field;

/**
 * @Author taozhaoyang
 * @Description //TODO $
 * @Date 2018/8/24 10:33
 **/
public class MainTest {

    public static void main(String[] args) throws IllegalAccessException, NoSuchFieldException {
        toBinary(8);
    }


    public  static void  getUnsafe() throws IllegalAccessException, NoSuchFieldException{
        //Unsafe unsafe = Unsafe.getUnsafe();

        Field field = Unsafe.class.getDeclaredField("theUnsafe");
        field.setAccessible(true);
        Unsafe unsafe = (Unsafe) field.get(null);
        System.out.println(unsafe);
    }

    public static  void toBinary(int num){
        String str = "";
        while (num != 0){
            str = num % 2 + str;
            num = num / 2;
        }
        System.out.println(str);
        int num2 = Integer.parseInt(str,2);
        System.out.println(num2);
    }
}
